package com.mark.migration.service.impl;

import com.mark.migration.service.ApArticleService;
import com.mark.model.article.pojos.ApArticle;
import com.mark.model.mappers.app.ApArticleMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description :  Ap文章服务
 * @Author :  Markburt
 * @CreateDate :  2020/3/5$ 下午 02:23$
 * @UpdateUser :  Markburt
 * @UpdateDate :  2020/3/5$ 下午 02:23$
 * @UpdateRemark :  Project Build
 * @Version :  1.0
 */
@Service
@Slf4j
@SuppressWarnings("all")
public class ApArticleServiceImpl implements ApArticleService {


    @Autowired
    private ApArticleMapper apArticleMapper;

    /**
     * 按Id获取
     *
     * @param id
     * @return
     */
    @Override
    public ApArticle getById(Long id) {
        return apArticleMapper.selectById(id);
    }

    /**
     * 查询未同步的数据
     *
     * @return
     */
    @Override
    public List<ApArticle> getUnSyncArticleList() {

        ApArticle apArticle = new ApArticle();
        apArticle.setSyncStatus(false);

        return apArticleMapper.selectList(apArticle);
    }

    /**
     * 更新同步状态
     *
     * @param apArticle
     */
    @Override
    public void updateSyncStatus(ApArticle apArticle) {
        //输出日志显示
        log.info("开始更新数据同步状态,aparticle:{}",apArticle);

        if (apArticle != null){
        apArticle.setSyncStatus(true);
        apArticleMapper.updateSyncStatus(apArticle);
        }
    }
}
